/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.GrantRequest;

import java.awt.Window;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;


/**
 * A list of Grant Requests.
 * Support showing the list
 * Can be filtered using Filters.
 * @author ohad
 */
public class GrantRequestsList implements Collection<GrantRequest>, Cloneable{

    // When cloning a list, actually copy it, so that filtering in one list doesn't affect the second one.
    @Override
    @SuppressWarnings("unchecked")
    protected Object clone() throws CloneNotSupportedException {
        GrantRequestsList newList=new GrantRequestsList((Collection<GrantRequest>)grantRequestsList.clone());
        return newList;
    }

    private ArrayList<GrantRequest> grantRequestsList;

    GrantRequestsList() {
        grantRequestsList=new ArrayList<GrantRequest>();
    }

    GrantRequestsList(Collection<GrantRequest> c) {
        grantRequestsList=new ArrayList<GrantRequest>(c);
    }
    
    @Override
    public int size() {
        return (grantRequestsList.size());
    }

    @Override
    public boolean isEmpty() {
        return (grantRequestsList.isEmpty());
    }

    @Override
    public boolean contains(Object o) {
        return (grantRequestsList.contains(o));
    }

    @Override
    public Iterator<GrantRequest> iterator() {
        return (grantRequestsList.iterator());
    }

    @Override
    public Object[] toArray() {
        return (grantRequestsList.toArray());
    }

    @Override
    public <T> T[] toArray(T[] a) {
        T[] res=(T[]) grantRequestsList.toArray(a);
        return(res);
    }

    @Override
    public boolean add(GrantRequest e) {
        return(grantRequestsList.add(e));
    }

    @Override
    public boolean remove(Object o) {
        return(grantRequestsList.remove(o));
    }

    @Override
    public boolean containsAll(Collection<?> c) {
        return(grantRequestsList.containsAll(c));
    }

    @Override
    public boolean addAll(Collection<? extends GrantRequest> c) {
        return(grantRequestsList.addAll(c));
    }

    @Override
    public boolean removeAll(Collection<?> c) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean retainAll(Collection<?> c) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void clear() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    // shows the list
    public void show(Window parent, String title) {
        new GrantRequestsListView(parent, this, title);
    }
}
